from flask import Blueprint, jsonify
from .tasks import sync_task_alerts, clean_expired_tokens

main = Blueprint('main', __name__)


@main.route('/sync', methods=['GET'])
def sync():
    sync_task_alerts()
    return jsonify({"message": "Task alerts synchronized successfully."})


@main.route('/clean-tokens', methods=['GET'])
def clean_tokens():  # 修改函数名称为唯一的 clean_tokens
    clean_expired_tokens()
    return jsonify({"message": "Expired tokens cleaned successfully."})
